/**
 * 面试题 08.01. 三步问题
 */
public class WaysToStep {
    public int waysToStep(int n) {
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        int MOD = 1000000007;
        int a = 1;
        int b = 2;
        int c = 4;
        for (int i = 4; i <= n; i++) {
            int cur = ((a + b) % MOD + c) % MOD; // 除余只能保证当前一个数符合要求所以每两个相加都要进行求余
            a = b;
            b = c;
            c = cur;
        }
        return c;
    }
}
